<template>
	<view class="">
		<Navtop :searchShow="false" :title="info.category_name" backUrl="back"></Navtop>
		<view class="container" :style="{paddingTop:statusBarHeight+47+'px'}">
			<block v-for="item in shopList " :key="item.mer_id">
				<shopItem :detail="item"></shopItem>
			</block>
		</view>
		<Loadmore :show="true" :state="loadState"></Loadmore>
		<Nohave :show="shopList.length>0?false:true"></Nohave>
	</view>
</template>

<script>
var statusBarHeight = uni.getSystemInfoSync().statusBarHeight;	


import { getShopList } from "@/api/localLife/home.js"

import Loadmore from './component/load.vue'
import Nohave from './component/noHave.vue';
import Navtop from "./component/navTop.vue";
import shopItem from './component/shopItem.vue'
export default{
	components:{shopItem,Navtop,Loadmore,Nohave},
	data(){
		return {
			// 请求对象
			form:{
				limit:10,
				page:1,
				classId:0
			},
			// 分类信息
			info:{},
			shopList:[],
			shopCount:-1,
			statusBarHeight:statusBarHeight,
			loadState:0,
		}
	},
	onLoad(options) {
		if(options.info){
			this.info = JSON.parse(options.info)
		}
		this.togetShopList();
	},
	methods:{
		togetShopList(){
			this.loadState = 0;
			getShopList({...this.form,category_id:this.info.merchant_category_id}).then((res)=>{
				this.shopList = res.data.list;
				this.shopCount = res.data.count
				if(this.shopList.length >=this.shopCount)
				{
					this.loadState = 2
				}else{
					this.loadState = 1
				}
				
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.container{
	margin: 0 20rpx;
}

</style>